home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test_codecmaps_jp.py < prev    next >
Text File  |  2005-10-18  |  3KB  |  80 lines

  1. #!/usr/bin/env python
  2. #
  3. # test_codecmaps_jp.py
  4. #   Codec mapping tests for Japanese encodings
  5. #
  6. # $CJKCodecs: test_codecmaps_jp.py,v 1.3 2004/06/19 06:09:55 perky Exp $
  7.  
  8. from test import test_support
  9. from test import test_multibytecodec_support
  10. import unittest
  11.  
  12. class TestCP932Map(test_multibytecodec_support.TestBase_Mapping,
  13.                    unittest.TestCase):
  14.     encoding = 'cp932'
  15.     mapfilename = 'CP932.TXT'
  16.     mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/' \
  17.                  'WINDOWS/CP932.TXT'
  18.     supmaps = [
  19.         ('\x80', u'\u0080'),
  20.         ('\xa0', u'\uf8f0'),
  21.         ('\xfd', u'\uf8f1'),
  22.         ('\xfe', u'\uf8f2'),
  23.         ('\xff', u'\uf8f3'),
  24.     ]
  25.     for i in range(0xa1, 0xe0):
  26.         supmaps.append((chr(i), unichr(i+0xfec0)))
  27.  
  28.  
  29. class TestEUCJPCOMPATMap(test_multibytecodec_support.TestBase_Mapping,
  30.                          unittest.TestCase):
  31.     encoding = 'euc_jp'
  32.     mapfilename = 'EUC-JP.TXT'
  33.     mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JP.TXT'
  34.  
  35.  
  36. class TestSJISCOMPATMap(test_multibytecodec_support.TestBase_Mapping,
  37.                         unittest.TestCase):
  38.     encoding = 'shift_jis'
  39.     mapfilename = 'SHIFTJIS.TXT'
  40.     mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/OBSOLETE' \
  41.                  '/EASTASIA/JIS/SHIFTJIS.TXT'
  42.     pass_enctest = [
  43.         ('\x81_', u'\\'),
  44.     ]
  45.     pass_dectest = [
  46.         ('\\', u'\xa5'),
  47.         ('~', u'\u203e'),
  48.         ('\x81_', u'\\'),
  49.     ]
  50.  
  51. class TestEUCJISX0213Map(test_multibytecodec_support.TestBase_Mapping,
  52.                          unittest.TestCase):
  53.     encoding = 'euc_jisx0213'
  54.     mapfilename = 'EUC-JISX0213.TXT'
  55.     mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JISX0213.TXT'
  56.  
  57.  
  58. class TestSJISX0213Map(test_multibytecodec_support.TestBase_Mapping,
  59.                        unittest.TestCase):
  60.     encoding = 'shift_jisx0213'
  61.     mapfilename = 'SHIFT_JISX0213.TXT'
  62.     mapfileurl = 'http://people.freebsd.org/~perky/i18n/SHIFT_JISX0213.TXT'
  63.  
  64.  
  65. def test_main():
  66.     suite = unittest.TestSuite()
  67.     suite.addTest(unittest.makeSuite(TestCP932Map))
  68.     suite.addTest(unittest.makeSuite(TestEUCJPCOMPATMap))
  69.     suite.addTest(unittest.makeSuite(TestSJISCOMPATMap))
  70.     suite.addTest(unittest.makeSuite(TestEUCJISX0213Map))
  71.     suite.addTest(unittest.makeSuite(TestSJISX0213Map))
  72.     test_support.run_suite(suite)
  73.  
  74. test_multibytecodec_support.register_skip_expected(TestCP932Map,
  75.     TestEUCJPCOMPATMap, TestSJISCOMPATMap, TestEUCJISX0213Map,
  76.     TestSJISX0213Map)
  77.  
  78. if __name__ == "__main__":
  79.     test_main()
  80.